package com.redepronik.negosys.invfac.entity;

import java.io.Serializable;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import org.hibernate.annotations.IndexColumn;

/**
 * The persistent class for the local database table.
 * 
 */
@Entity
@Table(schema = "invfac", name = "local")
@NamedQuery(name = "Local.findAll", query = "SELECT l FROM Local l")
public class Local implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@SequenceGenerator(allocationSize = 1, name = "LOCAL_LOCALID_GENERATOR", sequenceName = "INVFAC.LOCAL_LOCALID_SEQ")
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "LOCAL_LOCALID_GENERATOR")
	@Column(unique = true, nullable = false)
	private Integer localid;

	@Column(nullable = false)
	private Boolean activo;

	@Column(nullable = false, length = 100)
	private String ciudad;

	@Column(length = 100)
	private String direccion;

	@Column(nullable = false, length = 50)
	private String nombre;

	// bi-directional many-to-one association to Bodegalocal
	@OneToMany(orphanRemoval = true, cascade = CascadeType.ALL, mappedBy = "local")
	@IndexColumn(name = "orden", base = 1)
	private List<Bodegalocal> bodegalocals;

	// bi-directional many-to-one association to Egreso
	@OneToMany(orphanRemoval = true, cascade = CascadeType.ALL, mappedBy = "local")
	private List<Egreso> egresos;

	// bi-directional many-to-one association to Localempleadocargo
	@OneToMany(orphanRemoval = true, cascade = CascadeType.ALL, mappedBy = "local")
	private List<Localempleadocargo> localempleadocargos;

	public Local() {
	}

	public Bodegalocal addBodegalocal(Bodegalocal bodegalocal) {
		getBodegalocals().add(bodegalocal);
		bodegalocal.setLocal(this);

		return bodegalocal;
	}

	public Egreso addEgreso(Egreso egreso) {
		getEgresos().add(egreso);
		egreso.setLocal(this);

		return egreso;
	}

	public Localempleadocargo addLocalempleadocargo(
			Localempleadocargo localempleadocargo) {
		getLocalempleadocargos().add(localempleadocargo);
		localempleadocargo.setLocal(this);

		return localempleadocargo;
	}

	public Boolean getActivo() {
		return this.activo;
	}

	public List<Bodegalocal> getBodegalocals() {
		return this.bodegalocals;
	}

	public String getCiudad() {
		return this.ciudad;
	}

	public String getDireccion() {
		return this.direccion;
	}

	public List<Egreso> getEgresos() {
		return this.egresos;
	}

	public List<Localempleadocargo> getLocalempleadocargos() {
		return this.localempleadocargos;
	}

	public Integer getLocalid() {
		return this.localid;
	}

	public String getNombre() {
		return this.nombre;
	}

	public Bodegalocal removeBodegalocal(Bodegalocal bodegalocal) {
		getBodegalocals().remove(bodegalocal);
		bodegalocal.setLocal(null);

		return bodegalocal;
	}

	public Egreso removeEgreso(Egreso egreso) {
		getEgresos().remove(egreso);
		egreso.setLocal(null);

		return egreso;
	}

	public Localempleadocargo removeLocalempleadocargo(
			Localempleadocargo localempleadocargo) {
		getLocalempleadocargos().remove(localempleadocargo);
		localempleadocargo.setLocal(null);

		return localempleadocargo;
	}

	public void setActivo(Boolean activo) {
		this.activo = activo;
	}

	public void setBodegalocals(List<Bodegalocal> bodegalocals) {
		this.bodegalocals = bodegalocals;
	}

	public void setCiudad(String ciudad) {
		this.ciudad = ciudad;
	}

	public void setDireccion(String direccion) {
		this.direccion = direccion;
	}

	public void setEgresos(List<Egreso> egresos) {
		this.egresos = egresos;
	}

	public void setLocalempleadocargos(
			List<Localempleadocargo> localempleadocargos) {
		this.localempleadocargos = localempleadocargos;
	}

	public void setLocalid(Integer localid) {
		this.localid = localid;
	}

	public void setNombre(String nombre) {
		this.nombre = nombre;
	}

}